/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client.ihm.view;

import common.model.Visitor;
import java.awt.Color;
import java.awt.geom.GeneralPath;

/**
 *
 * @author nicolas
 */
public class VisitorSprite2D {

    //Variables declarations
    protected Visitor visitor = null;
    protected Color color = Color.BLACK;
    private Color DEFAULTCOLOR = Color.BLUE;
    private int w = 16;
    private int l = 16;
    private int xPoints[] = new int[5];
    private int yPoints[] = new int[5];
    private GeneralPath polygon; //GeneralPath implements Shape

    public VisitorSprite2D(VisitorLayer2D view, Visitor v) {
        this.visitor = v;

        //---Shape construction---
        polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length);
        //Points definitions
        xPoints[0] = -w / 2;
        xPoints[1] = -w / 2;
        xPoints[2] = 0;
        xPoints[3] = w / 2;
        xPoints[4] = 0;
        yPoints[0] = -l / 2;
        yPoints[1] = l / 2;
        yPoints[2] = l / 2;
        yPoints[3] = 0;
        yPoints[4] = -l / 2;
        //Construction
        polygon.moveTo(xPoints[0], yPoints[0]);
        for (int index = 1; index < xPoints.length; index++) {
            polygon.lineTo(xPoints[index], yPoints[index]);
        }
        polygon.closePath();
    }

    /**
     * Returns the color of the sprite given by the nature of the Visitor
     * (guide or not guide)
     * @return
     */
    public Color getColor() {
        if (this.visitor.isGuide()) {
            return Color.GREEN;
        }
        return DEFAULTCOLOR;
    }

    /**
     * Return the shape of the sprite
     * @return
     */
    public GeneralPath getShape(){
        return this.polygon;
    }

    public Visitor getVisitor() {
        return visitor;
    }

    public void setVisitor(Visitor visitor) {
        this.visitor = visitor;
    }
}
